#include "threadPool.hpp"
#include <ctime>
#include <cstdlib>
#include <unistd.h>

int main()
{
    srand(time(nullptr) ^ getpid());
    int cnt = 5;
    while (cnt--)
    {
        sleep(1);
        // 生产计算任务
        int x = rand() % 100 + 1;
        int y = rand() % 100 + 1;
        char opt = Task::getOperator(x + y);
        Task t(x, y, opt);

        // 输入计算任务

        //调用get_instance，访问唯一的线程池实例
        threadPool<Task>::get_instance()->pushTask(t);

        std::cout << "productor: " << t.equation() << "?" << std::endl;
    }

    std::cout << "ending..." << std::endl;


    return 0;
}